﻿using System;
using NUnit.Framework;
using Optparse;
using Optparse.Tester.Proxy;

namespace Gobo.Optparse.Tester {
    [TestFixture]
    public class TinyCharBufferTester {
        [Test]
        public void TestAppend() {
            TinyCharBufferProxy proxy = new TinyCharBufferProxy(5);
            proxy.Append('h');
            proxy.Append('e');
            proxy.Append('l');
            proxy.Append('l');
            proxy.Append('o');
            proxy.Append(' ');

            proxy.Append('w');
            proxy.Append('o');
            proxy.Append('r');
            proxy.Append('l');
            proxy.Append('d');
            proxy.Append('!');

            Assert.AreEqual("hello world!", proxy.ToString());
            Assert.AreEqual('!', proxy.Pop());
            Assert.AreEqual('d', proxy.Pop());
            Assert.AreEqual('l', proxy.Pop());
            Assert.AreEqual('r', proxy.Pop());

            Assert.AreEqual('o', proxy.Pop());
            Assert.AreEqual('w', proxy.Pop());
            Assert.AreEqual(' ', proxy.Pop());

            Assert.AreEqual('o', proxy.Pop());
            Assert.AreEqual('l', proxy.Pop());
            Assert.AreEqual('l', proxy.Pop());
            Assert.AreEqual('e', proxy.Pop());
            Assert.AreEqual('h', proxy.Pop());
            Assert.AreEqual('\0', proxy.Pop());

            Assert.AreEqual(string.Empty, proxy.ToString());
        }
    }
}
